package com.lsfb.signsys.editpwd;

import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;

/**
 * Created by zgscwjm on 2018/4/10.
 */

public class EditPwdPresenter implements EditPwdContract.EditPwdPresenter {

    EditPwdContract.EditPwdView mEditPwdView;

    EditPwdRepository mEditPwdRepository;

    CompositeDisposable mCompositeDisposable;

    public EditPwdPresenter(EditPwdContract.EditPwdView view) {
        this.mEditPwdView = view;
        mEditPwdRepository = new EditPwdRepository();
        mCompositeDisposable = new CompositeDisposable();
        mEditPwdView.setPresenter(this);

    }

    @Override
    public void subscribe() {

    }


    @Override
    public void unsubscribe() {
        mCompositeDisposable.clear();
    }

    @Override
    public void editpwd(String oldpwd, String newpwd) {

        mCompositeDisposable.clear();
        //判断过滤

        EditPwdTO editPwdTO = new EditPwdTO(oldpwd, newpwd);

        Disposable disposable = mEditPwdRepository.eidtPwd(editPwdTO).subscribe(editPwdBean -> {
            mEditPwdView.showMsg("修改成功");
        }, __ -> {
            mEditPwdView.showMsg("错误");
        }, () -> {

        });

        mCompositeDisposable.add(disposable);
    }
}
